Skip to content

Improved error handling#7

Merged
victorycodedev merged 1 commit into
mainfrom
feature/add_proper_error_message
Jun 18, 2026
Merged

Improved error handling#7
victorycodedev merged 1 commit into
mainfrom
feature/add_proper_error_message

Conversation

@victorycodedev

Copy link
Copy Markdown
Owner

Summary

This release improves error handling across the SDK and aligns MetaApiException with MetaApi's standard REST error model.

What's New

  • Added MetaApi error accessors:
    • id()
    • error()
    • message()
    • details()
    • toArray()
  • Normalized HTTP errors from custom Guzzle clients into MetaApiException
  • Wrapped connection and transport failures in MetaApiException
  • Preserved the original transport exception through getPrevious()
  • Enforced consistent SDK error handling for all HTTP clients
  • Updated error-handling documentation

Backward Compatibility

Existing methods remain supported:

  • errorId()
  • errorName()
  • getMessage()
  • response()

Example

try {
    $account = $metaapi->accounts()->readById('account-id');
} catch (MetaApiException $exception) {
    echo $exception->message();
    echo $exception->error();

    print_r($exception->details());
    print_r($exception->toArray());
}

@victorycodedev
victorycodedev merged commit 5904d22 into main Jun 18, 2026
12 checks passed
@victorycodedev
victorycodedev deleted the feature/add_proper_error_message branch June 18, 2026 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant